Hands-on Ex 2B

2nd Order Spatial Point Pattern Analysis Methods

Author

Stephen Tay

Published

August 31, 2024

Modified

September 3, 2024

1. Overview

This exercise focuses on second-order properties of spatial point patterns. Second-order properties examine the interactions between points, analyzing how these interactions influence the overall pattern. An example of a second-order property is the degree of dispersion — whether a point pattern is clustered, dispersed, or random. In general, distance-based methods, which consider the distances between pairs of points, are used to measure second-order properties.

As in the previous hands-on exercise on first-order spatial point pattern analysis, we will use the same geospatial R packages.

pacman::p_load(sf, spatstat, raster, maptools, tmap, tidyverse)

2. Importing & Transforming Data

As in the previous hands-on exercise, we will be importing the same three datasets:

  • Locations of childcare centers from data.gov.sg
  • Master Plan 2014 Subzone Boundary (Web) from data.gov.sg
  • National Coastal Boundary of Singapore from Singapore Land Authority (SLA)

Since the original datasets were in geographic coordinate system or had incorrect projection system, we will need to transform them to the same projection system.

childcare_sf <- st_read("data/geospatial/child-care-services-geojson.geojson") %>%
  st_transform(crs = 3414)
Reading layer `child-care-services-geojson' from data source 
  `/Users/stephentay/stephentay/ISSS626-Geospatial-Analytics/Hands-on_Ex/Hands-on_Ex02/data/geospatial/child-care-services-geojson.geojson' 
  using driver `GeoJSON'
Simple feature collection with 1545 features and 2 fields
Geometry type: POINT
Dimension:     XYZ
Bounding box:  xmin: 103.6824 ymin: 1.248403 xmax: 103.9897 ymax: 1.462134
z_range:       zmin: 0 zmax: 0
Geodetic CRS:  WGS 84
mpsz_sf <- st_read(dsn = "data/geospatial", layer = "MP14_SUBZONE_WEB_PL") %>%
  st_set_crs(3414)
Reading layer `MP14_SUBZONE_WEB_PL' from data source 
  `/Users/stephentay/stephentay/ISSS626-Geospatial-Analytics/Hands-on_Ex/Hands-on_Ex02/data/geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 323 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21
Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
that
sg_sf <- st_read(dsn = "data/geospatial", layer="CostalOutline") %>%
  st_set_crs(3414)
Reading layer `CostalOutline' from data source 
  `/Users/stephentay/stephentay/ISSS626-Geospatial-Analytics/Hands-on_Ex/Hands-on_Ex02/data/geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 60 features and 4 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 2663.926 ymin: 16357.98 xmax: 56047.79 ymax: 50244.03
Projected CRS: SVY21
Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
that

3. GeoVisualisation of Childcare Centers

It’s important to take a look at the spatial patterns of the childcare centers.

tm_shape(sg_sf) +
  tm_polygons() +
  tm_shape(mpsz_sf) +
  tm_polygons() +
  tm_shape(childcare_sf) +
  tm_dots(size = 0.01, alpha = 0.5)

An interactive pin map allows for free navigation and zooming across the map. You can easily query information about each point by clicking on it. Additionally, you have the option to change the background layer of the map.

tmap_mode('view')
tmap mode set to interactive viewing
tm_shape(childcare_sf)+
  tm_dots()
tmap_mode('plot')
tmap mode set to plotting

4. Geospatial Data Wrangling

4.1. Convert into spatstat’s ppp format

Here, we convert the childcare dataset into ppp format. We will also plot it and show the summary statistics of the created ppp object.

childcare_ppp <- as.ppp(childcare_sf)
Warning in as.ppp.sf(childcare_sf): only first attribute column is used for
marks
childcare_ppp
Marked planar point pattern: 1545 points
marks are of storage type  'character'
window: rectangle = [11203.01, 45404.24] x [25667.6, 49300.88] units
plot(childcare_ppp)
Warning in default.charmap(ntypes, chars): Too many types to display every type
as a different character
Warning: Only 10 out of 1545 symbols are shown in the symbol map

summary(childcare_ppp)
Marked planar point pattern:  1545 points
Average intensity 1.91145e-06 points per square unit

Coordinates are given to 11 decimal places

marks are of type 'character'
Summary:
   Length     Class      Mode 
     1545 character character 

Window: rectangle = [11203.01, 45404.24] x [25667.6, 49300.88] units
                    (34200 x 23630 units)
Window area = 808287000 square units

4.2 Checking and handling duplicated points

any(duplicated(childcare_ppp))
[1] FALSE
sum(multiplicity(childcare_ppp) > 1)
[1] 0
tmap_mode('view')
tmap mode set to interactive viewing
tm_shape(childcare_sf) +
  tm_dots(alpha=0.4, 
          size=0.05)
tmap_mode('plot')
tmap mode set to plotting

The simplest way to handle duplicated points is to delete them, but this approach may result in the loss of valuable data. Alternatively, you can use jittering, which applies a small perturbation to the duplicate points, ensuring they do not occupy the exact same location.

childcare_ppp_jit <- rjitter(childcare_ppp, 
                             retry=TRUE, 
                             nsim=1, 
                             drop=TRUE)
any(duplicated(childcare_ppp_jit))
[1] FALSE

4.3 Create owin object

When analyzing spatial point patterns, it is good practice to confine the analysis within a geographical boundary. This involves converting a spatial polygon into an owin object for use with the spatstat package later.

sg_owin <- as.owin(sg_sf)
plot(sg_owin)

summary(sg_owin)
Window: polygonal boundary
50 separate polygons (1 hole)
                 vertices         area relative.area
polygon 1 (hole)       30     -7081.18     -9.76e-06
polygon 2              55     82537.90      1.14e-04
polygon 3              90    415092.00      5.72e-04
polygon 4              49     16698.60      2.30e-05
polygon 5              38     24249.20      3.34e-05
polygon 6             976  23344700.00      3.22e-02
polygon 7             721   1927950.00      2.66e-03
polygon 8            1992   9992170.00      1.38e-02
polygon 9             330   1118960.00      1.54e-03
polygon 10            175    925904.00      1.28e-03
polygon 11            115    928394.00      1.28e-03
polygon 12             24      6352.39      8.76e-06
polygon 13            190    202489.00      2.79e-04
polygon 14             37     10170.50      1.40e-05
polygon 15             25     16622.70      2.29e-05
polygon 16             10      2145.07      2.96e-06
polygon 17             66     16184.10      2.23e-05
polygon 18           5195 636837000.00      8.78e-01
polygon 19             76    312332.00      4.31e-04
polygon 20            627  31891300.00      4.40e-02
polygon 21             20     32842.00      4.53e-05
polygon 22             42     55831.70      7.70e-05
polygon 23             67   1313540.00      1.81e-03
polygon 24            734   4690930.00      6.47e-03
polygon 25             16      3194.60      4.40e-06
polygon 26             15      4872.96      6.72e-06
polygon 27             15      4464.20      6.15e-06
polygon 28             14      5466.74      7.54e-06
polygon 29             37      5261.94      7.25e-06
polygon 30            111    662927.00      9.14e-04
polygon 31             69     56313.40      7.76e-05
polygon 32            143    145139.00      2.00e-04
polygon 33            397   2488210.00      3.43e-03
polygon 34             90    115991.00      1.60e-04
polygon 35             98     62682.90      8.64e-05
polygon 36            165    338736.00      4.67e-04
polygon 37            130     94046.50      1.30e-04
polygon 38             93    430642.00      5.94e-04
polygon 39             16      2010.46      2.77e-06
polygon 40            415   3253840.00      4.49e-03
polygon 41             30     10838.20      1.49e-05
polygon 42             53     34400.30      4.74e-05
polygon 43             26      8347.58      1.15e-05
polygon 44             74     58223.40      8.03e-05
polygon 45            327   2169210.00      2.99e-03
polygon 46            177    467446.00      6.44e-04
polygon 47             46    699702.00      9.65e-04
polygon 48              6     16841.00      2.32e-05
polygon 49             13     70087.30      9.66e-05
polygon 50              4      9459.63      1.30e-05
enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
                     (53380 x 33890 units)
Window area = 725376000 square units
Fraction of frame area: 0.401

4.4 Combine owin object with point events

In this final step of geospatial data wrangling, we will extract childcare events located within Singapore boundary using the code chunk below. The resulting object combines both point and polygon features into a single ppp object.

childcareSG_ppp = childcare_ppp[sg_owin]
summary(childcareSG_ppp)
Marked planar point pattern:  1545 points
Average intensity 2.129929e-06 points per square unit

Coordinates are given to 11 decimal places

marks are of type 'character'
Summary:
   Length     Class      Mode 
     1545 character character 

Window: polygonal boundary
50 separate polygons (1 hole)
                 vertices         area relative.area
polygon 1 (hole)       30     -7081.18     -9.76e-06
polygon 2              55     82537.90      1.14e-04
polygon 3              90    415092.00      5.72e-04
polygon 4              49     16698.60      2.30e-05
polygon 5              38     24249.20      3.34e-05
polygon 6             976  23344700.00      3.22e-02
polygon 7             721   1927950.00      2.66e-03
polygon 8            1992   9992170.00      1.38e-02
polygon 9             330   1118960.00      1.54e-03
polygon 10            175    925904.00      1.28e-03
polygon 11            115    928394.00      1.28e-03
polygon 12             24      6352.39      8.76e-06
polygon 13            190    202489.00      2.79e-04
polygon 14             37     10170.50      1.40e-05
polygon 15             25     16622.70      2.29e-05
polygon 16             10      2145.07      2.96e-06
polygon 17             66     16184.10      2.23e-05
polygon 18           5195 636837000.00      8.78e-01
polygon 19             76    312332.00      4.31e-04
polygon 20            627  31891300.00      4.40e-02
polygon 21             20     32842.00      4.53e-05
polygon 22             42     55831.70      7.70e-05
polygon 23             67   1313540.00      1.81e-03
polygon 24            734   4690930.00      6.47e-03
polygon 25             16      3194.60      4.40e-06
polygon 26             15      4872.96      6.72e-06
polygon 27             15      4464.20      6.15e-06
polygon 28             14      5466.74      7.54e-06
polygon 29             37      5261.94      7.25e-06
polygon 30            111    662927.00      9.14e-04
polygon 31             69     56313.40      7.76e-05
polygon 32            143    145139.00      2.00e-04
polygon 33            397   2488210.00      3.43e-03
polygon 34             90    115991.00      1.60e-04
polygon 35             98     62682.90      8.64e-05
polygon 36            165    338736.00      4.67e-04
polygon 37            130     94046.50      1.30e-04
polygon 38             93    430642.00      5.94e-04
polygon 39             16      2010.46      2.77e-06
polygon 40            415   3253840.00      4.49e-03
polygon 41             30     10838.20      1.49e-05
polygon 42             53     34400.30      4.74e-05
polygon 43             26      8347.58      1.15e-05
polygon 44             74     58223.40      8.03e-05
polygon 45            327   2169210.00      2.99e-03
polygon 46            177    467446.00      6.44e-04
polygon 47             46    699702.00      9.65e-04
polygon 48              6     16841.00      2.32e-05
polygon 49             13     70087.30      9.66e-05
polygon 50              4      9459.63      1.30e-05
enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
                     (53380 x 33890 units)
Window area = 725376000 square units
Fraction of frame area: 0.401
plot(childcareSG_ppp)
Warning in default.charmap(ntypes, chars): Too many types to display every type
as a different character
Warning: Only 10 out of 1545 symbols are shown in the symbol map

4.5 Extracting Area of Study

We will study the following areas: Punggol, Tampines, Choa Chu Kang and Jurong West planning areas.

pg <- mpsz_sf %>%
  filter(PLN_AREA_N == "PUNGGOL")
tm <- mpsz_sf %>%
  filter(PLN_AREA_N == "TAMPINES")
ck <- mpsz_sf %>%
  filter(PLN_AREA_N == "CHOA CHU KANG")
jw <- mpsz_sf %>%
  filter(PLN_AREA_N == "JURONG WEST")
plot(pg, main = "Punggol")
Warning: plotting the first 9 out of 15 attributes; use max.plot = 15 to plot
all

plot(tm, main = "Tampines")
Warning: plotting the first 9 out of 15 attributes; use max.plot = 15 to plot
all

plot(ck, main = "Choa Chu Kang")
Warning: plotting the first 10 out of 15 attributes; use max.plot = 15 to plot
all

plot(jw, main = "Jurong West")
Warning: plotting the first 9 out of 15 attributes; use max.plot = 15 to plot
all

pg_owin = as.owin(pg)
tm_owin = as.owin(tm)
ck_owin = as.owin(ck)
jw_owin = as.owin(jw)
childcare_pg_ppp = childcare_ppp_jit[pg_owin]
childcare_tm_ppp = childcare_ppp_jit[tm_owin]
childcare_ck_ppp = childcare_ppp_jit[ck_owin]
childcare_jw_ppp = childcare_ppp_jit[jw_owin]
childcare_pg_ppp.km = rescale(childcare_pg_ppp, 1000, "km")
childcare_tm_ppp.km = rescale(childcare_tm_ppp, 1000, "km")
childcare_ck_ppp.km = rescale(childcare_ck_ppp, 1000, "km")
childcare_jw_ppp.km = rescale(childcare_jw_ppp, 1000, "km")
par(mfrow=c(2,2))
plot(childcare_pg_ppp.km, main="Punggol")
Warning in default.charmap(ntypes, chars): Too many types to display every type
as a different character
Warning: Only 10 out of 61 symbols are shown in the symbol map
plot(childcare_tm_ppp.km, main="Tampines")
Warning in default.charmap(ntypes, chars): Too many types to display every type
as a different character
Warning: Only 10 out of 89 symbols are shown in the symbol map
plot(childcare_ck_ppp.km, main="Choa Chu Kang")
Warning in default.charmap(ntypes, chars): Too many types to display every type
as a different character
Warning: Only 10 out of 61 symbols are shown in the symbol map
plot(childcare_jw_ppp.km, main="Jurong West")
Warning in default.charmap(ntypes, chars): Too many types to display every type
as a different character
Warning: Only 10 out of 88 symbols are shown in the symbol map

5. Analysing Spatial Point Process Using G-Function

The G-function focuses on the distances between each event and its nearest neighboring event in a point pattern. It represents the cumulative distribution of these nearest neighbor distances. In practice, you calculate the distance from each event to its closest neighboring event and then analyze the cumulative distribution of these distances to understand the spatial relationship between the points.

The chart below is the G-function of the childcare locations in CCK with reference curve for CSR, which is the homogeneous Poisson point process. The G-function here has taken a certain edge correction procedure, which is out-of-scope for discussion.

G_CK = Gest(childcare_ck_ppp, correction = "border")
plot(G_CK, xlim=c(0,500))

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Choa Chu Kang are randomly distributed.
  • H1: The distribution of childcare services in Choa Chu Kang are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
G_CK.csr <- envelope(childcare_ck_ppp, Gest, correction = "border", nsim = 999, nrank = 1)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the G-function is within the boundary of the simulation envelope, the childcare locations in CCK exhibit a random pattern.

plot(G_CK.csr)

The chart below is the G-function of the childcare locations in Tampines with reference curve for CSR, which is the homogeneous Poisson point process. The G-function here has taken a certain edge correction procedure, which is out-of-scope for discussion.

G_tm = Gest(childcare_tm_ppp, correction = "best")
plot(G_tm)

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Tampines are randomly distributed.
  • H1: The distribution of childcare services in Tampines are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
G_tm.csr <- envelope(childcare_tm_ppp, Gest, correction = "best", nsim = 999, nrank = 1)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

The G-function is near the upper boundary of the simulation envelope. When we zoom in, we could see that the G-function has crossed the upper boundary for a certain range of distance, suggesting a clustered pattern.

plot(G_tm.csr)

6. Analysing Spatial Point Process Using F-Function

The F-function, also known as the empty space function, summarizes the characteristics of the nearest neighbor distances from a set of reference points to the nearest event in the point pattern. For each reference point, we calculate the distance to the closest event (a point in the pattern). Then, we take all these distances and construct a cumulative distribution, similar to how we do it for the G-function.

The chart below is the F-function of the childcare locations in CCK with reference curve for CSR. The chart shows some edge correction procedures, which is out-of-scope for discussion.

F_CK = Fest(childcare_ck_ppp)
plot(F_CK)

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Choa Chu Kang are randomly distributed.
  • H1: The distribution of childcare services in Choa Chu Kang are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
F_CK.csr <- envelope(childcare_ck_ppp, Fest, nsim = 999, nrank = 1)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the F-function is within the boundary of the simulation envelope, the childcare locations in CCK exhibit a random pattern.

plot(F_CK.csr)

The chart below is the F-function of the childcare locations in Tampines with reference curve for CSR. The F-function here has taken a certain edge correction procedure, which is out-of-scope for discussion.

F_tm = Fest(childcare_tm_ppp, correction = "best")
plot(F_tm)

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Tampines are randomly distributed.
  • H1: The distribution of childcare services in Tampines are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
F_tm.csr <- envelope(childcare_tm_ppp, Fest, correction = "best", nsim = 999, nrank = 1)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the F-function is below the lower boundary of the envelope, it implies clustering of childcare locations in Tampines.

plot(F_tm.csr)

7. Analysing Spatial Point Process Using K-Function

The K-function measures the expected number of events within a certain distance from an arbitrary event in a point pattern. To understand it, imagine drawing a circle of a given radius around each event and counting how many other points fall within those circles. The K-function calculates this expected number of points and compares it to what would be expected under complete spatial randomness. Specifically, the K-function is the observed number of points within a given distance, normalized by the intensity (average number of points per unit area), and then compared to the expected value under randomness. This helps to identify whether the point pattern is clustered, dispersed, or random at different scales.

The chart below is the K-function of the childcare locations in CCK with reference curve for CSR.

K_ck = Kest(childcare_ck_ppp, correction = "Ripley")
plot(K_ck, . -r ~ r, ylab= "K(d)-r", xlab = "d(m)")

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Choa Chu Kang are randomly distributed.
  • H1: The distribution of childcare services in Choa Chu Kang are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
K_ck.csr <- envelope(childcare_ck_ppp, Kest, nsim = 999, rank = 1, glocal=TRUE)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the K-function is within the boundary of the simulation envelope, the childcare locations in CCK exhibit a random pattern.

plot(K_ck.csr, . - r ~ r, xlab="d", ylab="K(d)-r")

The chart below is the K-function of the childcare locations in Tampines with reference curve for CSR.

K_tm = Kest(childcare_tm_ppp, correction = "Ripley")
plot(K_tm, . -r ~ r, 
     ylab= "K(d)-r", xlab = "d(m)", 
     xlim=c(0,1000))

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Tampines are randomly distributed.
  • H1: The distribution of childcare services in Tampines are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
K_tm.csr <- envelope(childcare_tm_ppp, Kest, nsim = 999, rank = 1, glocal=TRUE)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the K-function is clearly above the randomisation envelope, it strongly suggests significant clustering of childcare centers in Tampines.

plot(K_tm.csr, . - r ~ r, 
     xlab="d", ylab="K(d)-r", xlim=c(0,500))

8. Analysing Spatial Point Process Using L-Function

The L-function is a transformation of the K-function that adjusts for the increasing variance as distance increases. As the distance grows, the circles used in the K-function become larger, leading to more variability in the number of points within them. The L-function stabilizes this variance

The chart below is the L-function of the childcare locations in CCK with reference line for CSR.

L_ck = Lest(childcare_ck_ppp, correction = "Ripley")
plot(L_ck, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Choa Chu Kang are randomly distributed.
  • H1: The distribution of childcare services in Choa Chu Kang are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
L_ck.csr <- envelope(childcare_ck_ppp, Lest, nsim = 99, rank = 1, glocal=TRUE)
Generating 99 simulations of CSR  ...
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 
99.

Done.

Since the L-function is within the boundary of the simulation envelope, the childcare locations in CCK exhibit a random pattern.

plot(L_ck.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

The chart below is the L-function of the childcare locations in Tampines with reference line for CSR.

L_tm = Lest(childcare_tm_ppp, correction = "Ripley")
plot(L_tm, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)", 
     xlim=c(0,1000))

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Tampines are randomly distributed.
  • H1: The distribution of childcare services in Tampines are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
L_tm.csr <- envelope(childcare_tm_ppp, Lest, nsim = 999, rank = 1, glocal=TRUE)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the L-function is clearly above the randomisation envelope, it strongly suggests significant clustering of childcare centers in Tampines.

plot(L_tm.csr, . - r ~ r, 
     xlab="d", ylab="L(d)-r", xlim=c(0,500))

9. Analysing Spatial Point Process Using J-Function

The J-function combines information from the F-function and the G-function, to compare the observed point pattern against CSR.

The chart below is the J-function of the childcare locations in CCK with reference line for CSR.

J_CK = Jest(childcare_ck_ppp)
plot(J_CK)

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Choa Chu Kang are randomly distributed.
  • H1: The distribution of childcare services in Choa Chu Kang are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
J_CK.csr <- envelope(childcare_ck_ppp, Jest, nsim = 999, nrank=1)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

Since the J-function is near one and within the envelope, the childcare locations in CCK exhibit a random pattern.

plot(J_CK.csr)

The chart below is the J-function of the childcare locations in Tampines with reference line for CSR.

J_tm = Jest(childcare_tm_ppp, correction = "best")
plot(J_tm)

The test hypotheses are as follows:

  • H0: The distribution of childcare services in Tampines are randomly distributed.
  • H1: The distribution of childcare services in Tampines are not randomly distributed.

Alpha is set at 0.001, with 999 Monte-carlo simulations.

set.seed(2024)
J_tm.csr <- envelope(childcare_tm_ppp, Jest, correction = "best", nsim = 999, nrank=1)
Generating 999 simulations of CSR  ...
1, 2, 3, ......10.........20.........30.........40.........50.........60..
.......70.........80.........90.........100.........110.........120.........130
.........140.........150.........160.........170.........180.........190........
.200.........210.........220.........230.........240.........250.........260......
...270.........280.........290.........300.........310.........320.........330....
.....340.........350.........360.........370.........380.........390.........400..
.......410.........420.........430.........440.........450.........460.........470
.........480.........490.........500.........510.........520.........530........
.540.........550.........560.........570.........580.........590.........600......
...610.........620.........630.........640.........650.........660.........670....
.....680.........690.........700.........710.........720.........730.........740..
.......750.........760.........770.........780.........790.........800.........810
.........820.........830.........840.........850.........860.........870........
.880.........890.........900.........910.........920.........930.........940......
...950.........960.........970.........980.........990........
999.

Done.

When we zoom into the chart, the J-function is below 1, implying clustering of childcare locations in Tampines.

plot(J_tm.csr)

10. Summary

The second-order spatial point pattern analysis using various functions indicates that the childcare centers in Choa Chu Kang (CCK) are randomly distributed, while those in Tampines exhibit a clustered pattern.